#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<unordered_map>
using namespace std;

void solve()
{
    string s; cin >> s;
    if (s.size() < 3 || s[0] != '1' || s[1] != '0' || s[2] == '0')
    {
        cout << "NO" << endl; return;
    }
    if (s.size() == 3 && s[2] == '1')
    {
        cout << "NO" << endl; return;
    }
    cout << "YES" << endl; return;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}